<?php

class Review extends MY_Controller
{
    public function __construct()
    {
        parent::__construct();
    }

    public function edit($id)
    {
        $id = intval($id);
        if(!$id || $id < 0)
            return false;

        $review = $this->post_model->get($id);
        
        if( $this->input->server('REQUEST_METHOD') == 'POST' && ($id == $this->input->post('id')) )
        {
            $post['content'] = $this->input->post('content');
            $post['active_time'] = date('Y-m-d H:i:s', time());
            if( !$this->post_model->update($post, $this->input->post('id')) )
            {
                //更新article active_time
                $this->post_model->update(array('active_time'=>date('Y-m-d H:i:s', time())), $review['pid']);

                header('location:/review/edit/'.$this->input->post('id'));
            }
            //header();跳转到详细页
            header('location:/article/detail/'.$review['pid']);
            exit;
        }

        

        $this->tpl->assign('review', $review);
        $this->tpl->display('review_edit.html');
    }

    public function del()
    {
        
    }

    public function get()
    {
        
    }

    public function get_list()
    { 
        
    }
}